"""
配置管理模块

管理所有API密钥和模型配置
"""
import os
from typing import Optional
from pydantic_settings import BaseSettings
from pydantic import Field


class Settings(BaseSettings):
    """应用配置类"""
    
    # DashScope API配置
    DASHSCOPE_API_KEY: str = Field(
        default="",
        description="DashScope API密钥"
    )
    
    # 模型配置
    QWEN_MODEL_NAME: str = Field(
        default="qwen-max",
        description="主对话模型名称（qwen-max/qwen-plus/qwen-turbo）"
    )
    
    MEMORY_MODEL_NAME: str = Field(
        default="qwen-turbo",
        description="记忆管理模型名称"
    )
    
    EMBEDDING_MODEL_NAME: str = Field(
        default="text-embedding-v3",
        description="嵌入模型名称"
    )
    
    # MCP服务器配置
    MCP_SERVER_URL: str = Field(
        default="",
        description="MCP服务器URL"
    )
    
    MCP_TRANSPORT: str = Field(
        default="streamable_http",
        description="MCP传输方式（streamable_http/sse）"
    )
    
    # 记忆系统配置
    ENABLE_LONG_TERM_MEMORY: bool = Field(
        default=False,
        description="是否启用长期记忆"
    )
    
    MEMORY_ON_DISK: bool = Field(
        default=False,
        description="是否将记忆持久化到磁盘"
    )
    
    # Agent配置
    AGENT_NAME: str = Field(
        default="智能助手",
        description="Agent名称"
    )
    
    MAX_ITERATIONS: int = Field(
        default=10,
        description="ReActAgent最大迭代次数"
    )
    
    ENABLE_THINKING: bool = Field(
        default=False,
        description="是否启用思考模式"
    )
    
    PARALLEL_TOOL_CALLS: bool = Field(
        default=True,
        description="是否启用并行工具调用"
    )
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        case_sensitive = True


# 创建全局配置实例
settings = Settings()
